<?php
namespace Admin\Controller;

use Think\Controller;

class IndexController extends Controller
{
    public function index()
    {
    	$list = M('category')->where('pid=5')->select();
    	$this->assign('list',$list);
//var_dump(I('post.'));
    	if(I('post.dosubmit')=='dosubmit'){

    		$data['pid'] = I('post.pid');
    		$data['detail'] = I('post.src');
    		$data['name'] = trim(trim(I('post.name'),pathinfo(I('post.name'),PATHINFO_EXTENSION)),'.');
    		//var_dump($data);
    		$res=M('detail')->add($data);
    		//var_dump($res);
    	}
        $this->display();
    }

    public function news(){
        
        $list = M('category')->where('pid=3')->select();
        $this->assign('list',$list);
        if(I('post.dosubmit')=='dosubmit'){

            $data['pid'] = I('post.pid');
            $data['detail'] = $_POST['content'];
            $data['name'] = I('post.name');
            $data['time'] = time();
            //var_dump($data);
            $res=M('detail')->add($data);
        }
        $this->display();
    }

    public function people(){
        
        $list = M('category')->where('pid=4')->select();
        $this->assign('list',$list);
        if(I('post.dosubmit')=='dosubmit'){

            $data['pid'] = I('post.pid');
            $data['detail'] = $_POST['content'];
            $data['name'] = I('post.name');
            $data['time'] = time();
            //var_dump($data);
            $res=M('detail')->add($data);
        }
        $this->display();
    }

    public function co(){

        $list = M('category')->where('pid=6')->select();
        $this->assign('list',$list);
        if(I('post.dosubmit')=='dosubmit'){

            $data['pid'] = I('post.pid');
            $data['detail'] = I('post.src');
            $data['name'] = trim(trim(I('post.name'),pathinfo(I('post.name'),PATHINFO_EXTENSION)),'.');
            //var_dump($data);
            $res=M('detail')->add($data);
            //var_dump($res);
        }
        $this->display();
    }
}